#!/bin/bash
#定义变量
##grub的硬盘
disk='/dev/sda'
##新建的第一个用户
user1=userr
##root和新用户的密码
password=admin
##设置的主机名
hostname=ArchLinux

###设置时区
echo "set timezone"
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
####设置时间标准为UTC
hwclock --systohc --utc
###配置Locale
cat >> /etc/locale.gen << EOF
en_US.UTF-8 UTF-8
EOF
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
echo ArchLinux > /etc/hostname
cat >> /etc/hosts << EOF
127.0.0.1    localhost.localdomain    localhost
::1          localhost.localdomain    localhost
127.0.1.1    $hostname.localdomain    $hostname
EOF
###设置root密码
echo "set root password"
echo "root:$password"|chpasswd
###创建用户
useradd -m -G wheel -s /bin/bash $user1
echo "$user1:$password"|chpasswd
###vim配置文件
cp /root/.vimrc /home/$user1
###安装软件包
grub-install --recheck $disk
grub-mkconfig -o /boot/grub/grub.cfg
###允许root,ssh
sed -i "/^#PermitRootLogin/cPermitRootLogin yes" /etc/ssh/sshd_config
sed -i "/^#PasswordAuthentication/cPasswordAuthentication yes" /etc/ssh/sshd_config
echo "NetworkManager sshd"
systemctl enable NetworkManager sshd
#手动输入以下命令,重启系统
echo "手动输入exit"
echo "手动输入umount -R /mnt"
echo "手动输入reboot"
exit
